<template>
    <div>

        <div id="container">

            <div class="main">
                <div class="breadcrumb">
                    <a @click="goHome()" title="博客吧">首页</a> &raquo; 正文内容
                </div>

                <div class="post" id="post-8434" v-if="dat">
                    <h1 class="postTitle">{{dat.title}}</h1>


                    <div class="postmeta">
                        <span class="date">{{changeTime(dat.inputtime)}}</span>

                        <span class='tags'><a href="tag\zbupdate\index.html"
                                              rel="tag">{{changeTime(dat.updatetime)}}</a></span>
                        <span class="views">{{dat.click}} ℃</span>
                        <span class="cmt">0 条评论</span>
                    </div>
                    <div class="entry" v-html="dat.content">

                    </div>
                </div>
            </div>


            <!--右边导航栏-->

            <div class="sidebar">

                <Rank @change="changeId"></Rank>

                <Tag></Tag>

            </div>
        </div>
    </div>
</template>

<script>
    import Tag from '../public/tag.vue'
    import Rank from '../public/rank.vue'
    import {CON} from '@/config/config.js'

    export default {
        name: 'content',
        components: {
            Tag, Rank

        },
        data() {
            return {
                dat: [],
                id: ''
            }

        },
        watch: {},

        activated() {
            document.body.scrollTop = 0
            document.documentElement.scrollTop = 0
            this.id = this.$route.query.id
            this.getContent();
        },

        methods: {
            getContent() {
                this.$http({
                    url: 'getArticleInfo',
                    method: 'get',
                    params: {id: this.id}
                }).then(res => {
                    this.dat = res.code === 200 ? res.data : [];
                })
            },
            /**
             *
             * */
            changeId(id) {

                this.id = id
                this.getContent()
            },

            /**
             * 回到首页
             * */
            goHome() {

                this.$router.push({path: '/'})
            },

            /**
             * 时间格式转换
             */
            changeTime(time) {

                return CON.changeTime(time)
            },

        }

    }
</script>

<style scoped>

</style>
